package im.route.api.header;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import im.route.api.util.DateUtil;

import java.io.Serializable;
import java.time.LocalDateTime;

@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class PAOCRequestHeader implements Serializable {
    private static final long serialVersionUID = 1760794128301014306L;

    private String apiId;
    private String transNo;
    private String reqChannelNo;
    private String rspChannelNo;
    private String sign;
    private String reqTime;
    private String infoContent;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String infoContentDecrypted;

    public PAOCRequestHeader() {
        this(null);
    }

    public PAOCRequestHeader(String apiId) {
        this.apiId = apiId;
    }

    public String getApiId() {
        return apiId;
    }

    public void setApiId(String apiId) {
        this.apiId = apiId;
    }

    public String getTransNo() {
        return transNo;
    }

    public void setTransNo(String transNo) {
        this.transNo = transNo;
    }

    public String getReqChannelNo() {
        return reqChannelNo;
    }

    public void setReqChannelNo(String reqChannelNo) {
        this.reqChannelNo = reqChannelNo;
    }

    public String getRspChannelNo() {
        return rspChannelNo;
    }

    public void setRspChannelNo(String rspChannelNo) {
        this.rspChannelNo = rspChannelNo;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getReqTime() {
        return reqTime;
    }

    public void setReqTime(String reqTime) {
        this.reqTime = reqTime;
    }

    public String getInfoContent() {
        return infoContent;
    }

    public void setInfoContent(String infoContent) {
        this.infoContent = infoContent;
    }

    public String getInfoContentDecrypted() {
        return infoContentDecrypted;
    }

    public void setInfoContentDecrypted(String infoContentDecrypted) {
        this.infoContentDecrypted = infoContentDecrypted;
    }

    public static String generateTranNo(String loanAcc, LocalDateTime dueDate, LocalDateTime sysDate, String dueDateFormat, String sysDateFormat) {
        StringBuilder sb = new StringBuilder();
        sb.append(loanAcc);
        sb.append(DateUtil.convertToString(dueDate, dueDateFormat));
        sb.append(DateUtil.convertToString(sysDate, sysDateFormat));
        return sb.toString();
    }

    @Override
    public String toString() {
        return "PAOCRequestHeader{" +
                "apiId='" + apiId + '\'' +
                ", transNo='" + transNo + '\'' +
                ", reqChannelNo='" + reqChannelNo + '\'' +
                ", rspChannelNo='" + rspChannelNo + '\'' +
                ", sign='" + sign + '\'' +
                ", reqTime='" + reqTime + '\'' +
                ", infoContent='" + infoContent + '\'' +
                '}';
    }
}
